<?php

/*
	This file is part of Mandragon.

    Mandragon is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Mandragon is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Mandragon.  If not, see <http://www.gnu.org/licenses/>.
*/

class AdminPage {

	private $alerter;
	private $access;
	private $toolbox;

	public function __construct() {
		$this->alerter = new Alerter();
		$this->access = new AccessManager();
		$this->toolbox = new Toolbox();
	}

	public function set_access_manager($access) {
		$this->access = $access;
	}

	public function set_alerter($alerter) {
		$this->alerter = $alerter;
	}

	public function set_toolbox($toolbox) {
		$this->toolbox = $toolbox;
	}

	/**
	 * adds extra access checks, dependent on page state
	 */
	function page_inc_check_access($page) {
		$this->access->check_access("ADMIN");
	}

	function page_inc_execute_action($page, $action) {

		switch($action) {
			default:
				$this->alerter->add_alert("unknown action: $action");
				break;
		}
	}

	/**
	 * execute page logic
	 */
	function page_inc_execute($page) {

		$this->toolbox->add_action($page, 'add_dir', 'url', '.edit_dir?action=add');
		$this->toolbox->add_action($page, 'user_management', 'url', '.usermgm');
		$this->toolbox->add_action($page, 'access', 'url', '.access');
		$this->toolbox->add_action($page, 'location', 'url', '.location');
		$this->toolbox->add_action($page, 'profiles', 'url', '.profile');
		$this->toolbox->add_action($page, 'maintenance', 'url', '.maintenance');
		$this->toolbox->add_action($page, 'logs', 'url', '.logs');
		$this->toolbox->add_action($page, 'mailcontents', 'url', '.mailcontentmgm');

		$page->content = array();
		$page->content['title'] = "Administrator panel";
		$page->content['body'] = "<p>Selecteer een van bovenstaande acties.</p>";
	}


	/**
	 * dress up page content using skin stuff
	 */
	function page_inc_dress($page) {
		print_body($page);
	}
}

?>